<?php
$html = new HtmlHelper($this);
echo $html->script('jquery');
echo $html->stylesheet('datepicker/jquery-ui-1.8.13.custom');
echo $html->script('datepicker/jquery-ui-1.8.13.custom.min'); 
?>
<script src="/scripts/highcharts/highcharts.js" type="text/javascript"></script>
<script type='text/javascript'>
var chart;
var example = 'pie-basic', theme = 'default';
Highcharts.theme = { colors: ['#4572A7'] }; // Prevent errors in default theme
var highchartsOptions = Highcharts.getOptions(); 
function confirma(id, nome, rowIndex) {
	if (confirm("Tem certeza que deseja excluir o cliente " + nome + "?")) {
		location.href="/cliente/excluir/"+id; 
		document.getElementById("formulario").deleteRow(rowIndex); //id da tabela + excluir linha 
	} else {
		return false;
	}
}
jQuery(document).ready(function() {
	chart = new Highcharts.Chart({
		chart: {
			renderTo: 'grafico',
			animation: true,
			plotBackgroundColor: null,
			plotBorderWidth: null,
			plotShadow: false,
			height: 309,
			width: 402
		},
		credits : {
			enabled: false
		},
		title: {
			text: null
		},
		tooltip: {
			formatter: function() {
				return '<b>'+ this.point.name +'</b>: '+ this.y +' %';
			}
		},
		plotOptions: {
			pie: {
				allowPointSelect: true,
				cursor: 'pointer',
				dataLabels: {
					enabled: true,
					color: Highcharts.theme.textColor || '#000000',
					connectorColor: Highcharts.theme.textColor || '#000000',
					formatter: function() {
						return '<b>'+ this.y +'%</b>';
					}
				}
			}
		},
		series: [{
			type: 'pie',
			name: 'Browser share',
			data: [<?php echo $sSliceChart; ?>]
		}]
	});
});
</script>
<div class="wrapper">
	<br><br>
	<div class="clear"></div>
	<div class="leadsCtn">
		<div class="title">
			<h4 class="left">
				<?php if($showChart != 2) : ?>
					Clientes
				<?php else : ?>
					Clientes Removidos
				<?php endif; ?>
			</h4>
			<div class="right" style="vertical-align: middle; margin-right: 10px; margin-top: 10px">
				 <?php echo $html->link('Criar novo cliente','/cliente/adicionar',array('class'=>'botaoCinza right peq')); ?>
			 </div>	
		</div>
		<div class="content">
			<div class="clear"></div>
			<table id="formulario">
				<thead>
					<tr>
						<th width="200px">Cliente</th>
						<th width="60px" style="text-align:center;">Status</th>
						<th width="200px">Plano</th>
						<th width="55px">Camp.</th>
						<th width="55px">Leads</th>
						<th width="100px">Email</th>
						<th width="80px">&nbsp;</th>
						<th width="80px">&nbsp;</th>
					</tr>
				</thead>
				<tbody>
				<?php foreach($arrCliente as $key => $objCliente) { ?>
					<?php $objCliente = (object) $objCliente; ?>
					<tr id="<?php echo $objCliente->clie_id; ?>" style="color:<?php echo $objCliente->color ?>">
						<td><?php echo $objCliente->clie_empresa; ?></td>
						<td align="center"><?php echo $objCliente->status_name ?></td>
						<td><?php echo $objCliente->plan_nome; ?></td>
						<td align="center"><?php echo $objCliente->count_camp; ?></td>
						<td align="center"><?php echo $objCliente->count_lead; ?></td>
						<td><?php echo $objCliente->clie_email; ?></td>
						<?php $editar_link = ($objCliente->clie_status == 2) ? '/cliente/editar/'.$objCliente->clie_id.'/removidos' : '/cliente/editar/'.$objCliente->clie_id; ?>
						<td><?php echo $html->link('Editar',$editar_link, array( 'class' => 'editarIcon' )); ?></td>
						<?php if($objCliente->clie_status == 2) : ?>
							<td><a border='0' class='deleteIcon' href='javascript:confirma("<?php echo $objCliente->clie_id ?>","<?php echo $objCliente->clie_empresa ?>","<?php echo $key+1 ?>")'>Deletar</a></td>
						<?php else : ?>
							<td><?php echo $html->link('Remover', '/cliente/remover/'.$objCliente->clie_id, array( 'class' => 'trashIcon' )); ?></td>
						<?php endif; ?>
					</tr>
				<?php } ?>
				</tbody>
			</table>
		</div>
	</div><!-- .leads -->
	<?php if($showChart != 2) :  ?>
		<div class="content" style="clear:both;height:350px;text-align:center;margin:0 auto;width:400px;">
			<div id="grafico" class="graph left" style="padding:20px 0 0 0;margin:0;float:right;"></div>
		</div>
	<?php endif; ?>           
</div><!-- .wraper -->